<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../css/stylesite.css" medial="all" />
<link rel="stylesheet" type="text/css" href="../css/styleleft.css" medial="all" />
<link rel="stylesheet" type="text/css" href="../css/mystyle.css" />
<script type="text/javascript" src="../js/jquery-1.8.2.min.js"></script>
<style>
    a{color: blue;}
    a:hover{color: #f80c0c;}
</style>
	<script src="../js/jquery-1.8.2.min.js" ></script>
	<script src="../js/image.js" type="text/javascript"></script>
         <script src="../js/jsearch.js" type="text/javascript"></script>  
	<script type="text/javascript">
		$(function (){
			$(".idThem").hide();
			$("#img").click(function(){
				$(".idThem").slideToggle();			
		});
		});
	          
	</script>
   <script type="text/javascript">
        var xmlHttp;
		function v_editCategory(str)
		{
                     var xmlHttp;
                if (window.XMLHttpRequest)
                {
                    // code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlHttp=new XMLHttpRequest();

                }
                else
                {
                    // code for IE6, IE5
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
		        xmlHttp.onreadystatechange=function()
                {
                    if (xmlHttp.readyState==4)
					{
                        if (xmlHttp.status == 200) 
						{
						// 	window.alert("test thoi");
				//            document.myform.anbum.value=xmlHttp.responseText;
                     		document.getElementById('content').innerHTML=xmlHttp.responseText;
                       }
                        else {
                            // Có lỗi! Thông báo ngay!
                            alert('Lỗi!!!');
                        }
                    }
                    else {
                        // loading…
                    }
                }
                var url='v_categoryEdit.php';
				var test;
				//test=document.getElementById('idselect').value;
				//test=document.myform.select1.value;
				url=url+"?ID_category="+str;
				
                xmlHttp.open("GET",url,true);
                xmlHttp.send(null);
		}
   
		
	</script>
   
<title>QUẢN LÝ DANH MỤC</title>
</head>

<body class="pagebody">
	<div id="wrapwebsite" >
            <?php 
            include('../element/header_adm.php');
			
                                ?>
            <div class="imagestop"></div>
            <div class="wrapmaincontent">
                <div id="maincontent">
                    <?php
                    if(!isset($_SESSION['user'])|| $_SESSION['user'][4]!='admin')
                        {      
                            echo '<p>Bạn không được quyền xem trang này</p>';
                             header ('location:/cfshop/home.php');
                        }
                        else
                        {
                    ?>
                    <p>Thêm danh mục</p>
                  <img src="../images/1318903087_add_small.ico" width="30px" height="30px" id="img" /> 
                  <div class="idThem">
              <form action="c_categoryAdd.php" method="get">
                  <table width="400px">
                  <tr>
                    <td width="150px">Category Name</td>
                    <td width="250px"><input style="font-size:18px; padding:5px; width:220px;margin-bottom: 5px " name="txtCateName" type="text" size="30px"/></td>
                  </tr>
                  <tr>
                    <td>Category</td>
                    <td>&nbsp; 
                    <select name="txtCate">
                    	<option value="1">Bánh</option>
                        <option value="2">Hoa</option>
                    </select>
                    </td>
                  </tr>
                  <tr>
                    <td>Visible</td>
                    <td>&nbsp; <select name="txtVisible">
                    	<option value="1">Yes</option>
                        <option value="0">No</option>
                    </select>
                    </td>
                  </tr>
                  <tr>
                   
                    <td align="center" colspan="2">&nbsp;  <input name="Them" type="submit" value="Thêm" class="button" /><input name="reset" type="reset" value="Reset" class="button" /></td>
                  </tr>
                </table>   
                </form>
                </div>
                  <div id="content">
           <?php        
                    include 'category_model.php';
          
                 //   getCategories();
                   
                    echo '<table class="table" border="0">';
                     echo '<tr align="center">';
                    echo '<td colspan="7"><b>CATEGORY LIST</b></td>';
                    echo '</tr>';
                    echo '<tr>';
                    echo '<td><b>CategoryID</b></td>';
                    echo '<td><b>CategoryName</b></td>';
                    echo '<td><b>Category</b></td>';
                    echo '<td><b>Visible</b></td>';
                    echo '<td><b>Edit Category</b></td>';
                    echo '<td><b>Delete Category</b></td>';
                    echo '<td ><b>Show product</b></td>';
                    echo '</tr>';
                   $conn=  getConnect();             
                    $sql="select * from categories order by isVisable desc ";
                    $result=  mysql_query($sql, $conn);
                    if(!$result)
                        die('Truy van ko hop le');
                    $loaisp=NULL;
                    while($row= mysql_fetch_assoc($result))
                    {
                        $ID=$row['CategoryID'];
                        if($row['ParentID']==1)
                            $loaisp="Bánh";
                        else
                            $loaisp="Hoa";
                        if($row['isVisable']==1)
                            $vi="Y";
                        else
                            $vi="N";
                        echo "<tr>";
                        echo "<td>".$row['CategoryID']."</td>";
                        echo "<td>".$row['CategoryName']."</td>";
                        echo "<td>".$loaisp."</td>";
                        echo "<td>".$vi."</td>";
                        echo '<td align="center"><img src="../images/1352648277_message_edit.png" width="30px" height="30px" onclick="v_editCategory('.$row['CategoryID'].')" /></td>';
                        echo '<td align="center"><a href="c_categoryAdd.php?ID_category='.$row['CategoryID'].'"><img src="../images/1318498996_DeleteRed.ico" width="30px" height="30px"  /></a></td>';
                        echo '<td align="center"><a href="../adm_Product/v_product_manage.php?ID_category='.$row['CategoryID'].'">Show Product<<<</a></td>';
                        echo '</tr>';
                    }      
                   //  $i+=1;
                  // }
                  mysql_close($conn);
               ?>
            </div> 
           </div>         
		<?php
                        }
                        ?>
</div>
</body>
</html>
